package com.campus.delivery.controller;

import com.campus.common.bean.common.Resp;
import com.campus.delivery.service.NoticeService;
import com.campus.delivery.vo.NoticeDetailVo;
import com.campus.delivery.vo.NoticeListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 公告表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-07-15
 */
@Api(tags = "公告相关接口")
@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;
    
    @ApiOperation("获取配送端公告列表")
    @GetMapping("/list")
    public Resp<List<NoticeListVo>> getDeliveryNoticeList() {
        List<NoticeListVo> noticeList = noticeService.getDeliveryNoticeList();
        return Resp.success(noticeList);
    }
    
    @ApiOperation("获取公告详情")
    @GetMapping("/detail/{id}")
    public Resp<NoticeDetailVo> getNoticeDetail(@PathVariable Integer id) {
        NoticeDetailVo noticeDetail = noticeService.getNoticeDetail(id);
        if (noticeDetail == null) {
            return Resp.error("公告不存在");
        }
        return Resp.success(noticeDetail);
    }
}
